package android.pot.com.smartcar.wxapi;


import android.content.Intent;
import android.os.Bundle;
import android.pot.com.smartcar.R;
import android.pot.com.smartcar.base.swipe.SwipeBackActivity;
import android.pot.com.smartcar.tool.TipToast;
import android.pot.com.smartcar.ui.home.activity.ProductDetailActivity;

import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

public class WXPayEntryActivity extends SwipeBackActivity implements IWXAPIEventHandler{
    private IWXAPI api;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pay_result);

        api = WXAPIFactory.createWXAPI(this, "wx17ec252bfac28859");
        api.handleIntent(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        api.handleIntent(intent, this);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void addListener() {

    }

    @Override
	public void onReq(BaseReq baseReq) {

	}

    @Override
	public void onResp(BaseResp resp) {

	switch (resp.errCode){
        case 0:
            TipToast.show("支付成功");
            startAct(WXPayEntryActivity.this,ProductDetailActivity.class);
            break;
        case  -1:
            TipToast.show("支付失败");
            startAct(WXPayEntryActivity.this,ProductDetailActivity.class);
            break;
        case  -2:
            TipToast.show("取消支付");
            startAct(WXPayEntryActivity.this,ProductDetailActivity.class);
            break;
    }
	}
}